import java.io.IOException;

import org.json.JSONException;

public class Main {
	private static double EPSILON = 0.00001;

	public static void main(String[] args) throws IOException, JSONException {
		QueryOptimizer q = QueryOptimizer.createQueryOptimizer();

		while (true) {
			q.executeQuery();
			q.judgeResponse();

			if (q.getCurrentPrecision() < EPSILON) {
				System.out.println("No relevent query returned! Exiting...");
				break;
			} else if (q.getCurrentPrecision() > q.getTargetPrecision()
					- EPSILON) {
				System.out.println("Target precision achieved! Exiting...");
				break;
			}

			q.improveQuery();
		}
	}
}
